Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V  < 1 2  
Reply to this topicStart new topic
> [PHP] Pobieranie danych ze strony
Dizzy
post
Post #21





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


curl_exec($ch)
Go to the top of the page
+Quote Post
wookieb
post
Post #22





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Nie no stary musze to w końcu powiedziec. Jesteś tak niesamowicie niekumaty, że ty nawet nie rozumiesz co się do ciebie mówi
PO curl_exec
Kod
var_dump($tekst);


I pokaż teraz cały swoj kod...

Ten post edytował wookieb 6.02.2009, 13:59:18
Go to the top of the page
+Quote Post
Dizzy
post
Post #23





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


No jest niestety: "bool(false)"
Go to the top of the page
+Quote Post
wookieb
post
Post #24





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Jeszcze to popraw...
Kod
$ch = curl_init($site);

U mnei też była literówka.
Go to the top of the page
+Quote Post
Dizzy
post
Post #25





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


string(85) " Invalid house id. "
Go to the top of the page
+Quote Post
wookieb
post
Post #26





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Pokaż zmienna $site.
Podpowiem ...\
Kod
var_dump($site);
Go to the top of the page
+Quote Post
Dizzy
post
Post #27





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


string(30) "http://erig.net/house/Empera/H

Źle pobiera $house :/

[Fortune Wing 3 (Yalahar) is paid until Feb 16 2009]
Go to the top of the page
+Quote Post
wookieb
post
Post #28





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Kod
$site="http://erig.net/house/$world[1]/".$house[1];


Ten post edytował wookieb 6.02.2009, 14:19:07
Go to the top of the page
+Quote Post
Dizzy
post
Post #29





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Kod teraz wygląda tak:
  1. <?php
  2.    // getdata.php
  3.    // by ufo ;)
  4.    // get Tibia character info from tibia.com
  5.    //
  6.    // usage:
  7.    // call this script from some webbrowser giving character name as a GET parameter
  8.    //
  9.    // example:
  10.    // getdata.php?char=Bubble
  11.    // getdata.php?char=Eternal Oblivion
  12.    
  13.    $character = urlencode($_GET[char]);
  14.    
  15.    // patterns
  16.    $name = "|Name:</TD><TD>([^<]+)?</TD>|i";
  17.    $sex = "|Sex:</TD><TD>([^<]+)?</TD>|i";
  18.    $profession = "|Profession:</TD><TD>([^<]+)?</TD>|i";
  19.    $level = "|Level:</TD><TD>([^<]+)?</TD>|i";
  20.    $world = "|World:</TD><TD>([^<]+)?</TD>|i";
  21.    $residence = "|Residence:</TD><TD>([^<]+)?</TD>|i";
  22.    $house = "|House:</TD><TD>([^<]+)?</TD>|i";
  23.    $guild = "|Guild[^<]*?</TD><TD>([^<]+)?<A[^>]*?>([^<]+)?</A></TD>|i";
  24.    $account = "|Account[^<]*?</TD><TD>([^<]+)?</TD>|i";
  25.    
  26.    // get page source
  27.    $page = file_get_contents("http://www.tibia.com/community/?subtopic=characters&name=$character");
  28.    
  29.    // Formatowanie
  30.    
  31.    $dom = "|House:</TD><TD>([^<]+)?<A[^>]*?>([^<]+)?</A></TD>|i";
  32.    // look for matches
  33.    preg_match($name, $page, $name);
  34.    preg_match($sex, $page, $sex);
  35.    preg_match($profession, $page, $profession);
  36.    preg_match($level, $page, $level);
  37.    preg_match($world, $page, $world);
  38.    preg_match($residence, $page, $residence);
  39.    preg_match($house, $page, $house);
  40.    preg_match($guild, $page, $guild);
  41.    preg_match($account, $page, $account);
  42.    
  43.    // show captured data
  44.    echo "Character name: [". $name[1] ."]<br>";
  45.    echo "Sex: [". $sex[1] ."]<br>";
  46.    echo "Profession: [". $profession[1] ."]<br>";
  47.    echo "Level: [". $level[1] ."]<br>";
  48.    echo "World: [". $world[1] ."]<br>";
  49.    echo "Residence: [". $residence[1] ."]<br>";
  50.    echo "House: [". ($house[1] == '' ? 'None' : $house[1]) ."]<br>";
  51.    echo "Guild membership: [". ($guild[1] . $guild[2] == '' ? 'None' : $guild[1] . $guild[2]) ."]<br>";
  52.    echo "Account Status: [". $account[1] ."]<br>";
  53.    
  54.    $site="http://erig.net/house/$world[1]/".$house[1];
  55.  
  56.    $ch = curl_init($site);
  57.    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  58.    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  59.    $tekst=curl_exec($ch);
  60.    var_dump($tekst);
  61.    var_dump($site);
  62.    curl_close($ch);
  63.        
  64.    $token = "<img=([^<]+)?>|i";
  65.  
  66.    preg_match ('|<IMG SRC="http://static.tibia.com/images/houses/(.*?)" WIDTH=150 HEIGHT=150>|U', $tekst, $token);
  67.    echo'<IMG SRC="http://static.tibia.com/images/houses/'.$token[1].'" WIDTH=150 HEIGHT=150>';
  68.        print_r($token)
  69. ?>
  70.  
  71.  
  72. <a href="#" onmouseover="return escape('<img src=http://static.tibia.com/images/houses/house_50201.jpg width=192 height=192>')">Castle Street 1 </a>
  73. <script language="JavaScript" type="text/javascript" src="wz_tooltip.js"></script>
Go to the top of the page
+Quote Post
wookieb
post
Post #30





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




  1. <?php
  2. preg_match('/(.*?)(/', $house[1], $dom);
  3.    
  4.   $site="http://erig.net/house/$world[1]/".str_replace(' ', '', $dom[1]);
  5.    
  6.   $ch = curl_init($site);
  7.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8.   $tekst=curl_exec($ch);
  9.    
  10.    if(preg_match_all('/<input type="hidden" name="(.*?)" value="(.*?)" />/', $tekst, $postData, PREG_SET_ORDER))
  11.    {
  12.        $post=array();
  13.        
  14.        foreach($postData as $dt)
  15.        {
  16.            $post[$dt[1]]=$dt[2];
  17.        }
  18.        
  19.        $site='http://www.tibia.com/community/?subtopic=houses&page=view';
  20.        
  21.        $ch = curl_init($site);
  22.        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  23.        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  24.        $tekst=curl_exec($ch);
  25.        
  26.        preg_match ('|<IMG SRC="http://static.tibia.com/images/houses/(.*?)" WIDTH=150 HEIGHT=150>|U', $tekst, $token);
  27.        echo'<IMG SRC="http://static.tibia.com/images/houses/'.$token[1].'" WIDTH=150 HEIGHT=150>';
  28.        
  29.    }
  30.    else
  31.    {
  32.        echo 'BEZDOMNY';
  33.    }
  34. ?>
Go to the top of the page
+Quote Post
Dizzy
post
Post #31





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Ooo działa, wielkie dzięki za pomoc. (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

2 Stron V  < 1 2
Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 07:08